
require_relative 'hand.rb'

# Represents a card game player.
class Player
  attr_reader :name, :last_card_played

  # Create a player with the given name.
  def initialize name
    @name = name
    @hand = Hand.new
    @last_card_played = nil # last card played by the player
  end

  # Give the player a hand to play.
  def set_hand hand
    @hand = hand
  end

  # Return a random card from the hand.
  def play
    @last_card_played = @hand.pick_random
  end

  # Return a string that represents this player and their hand.
  def to_s
    @name + ": " + @hand.to_string
  end

end
